using System.Web.UI.WebControls;

namespace LeanUi.ImageBundle
{
    public class ImageSprite
    {
        private readonly string _src;
        private readonly string _cls;

        public ImageSprite(string src)
        {
            _src = src;
            _cls = NamingHelper.GetSpriteClassFor(src);
        }
        public ImageSprite(string src, string cls)
        {
            _src = src;
            _cls = cls;
        }

        public Image Control
        {
            get
            {
                var spriteNullGif = ImageBundleDirs.ImageFile("null.gif");
                return new Image { ImageUrl = spriteNullGif, CssClass = _cls };
            }
        }
        public Image ControlNoSprite
        {
            get
            {
                var src = ImageBundleDirs.ImageFile(_src);
                return new Image { ImageUrl = src };
            }
        }

        public string Markup
        {
            get
            {
                var spriteNullGif = ImageBundleDirs.ImageFile("null.gif");  
                return string.Format("<img src=\"{0}\" class=\"{1}\"/>", spriteNullGif, _cls);
            }
        }
        public string MarkupNoSprite
        {
            get
            {
                var src = ImageBundleDirs.ImageFile(_src);
                return string.Format("<img src=\"{0}\"/>", src);
            }
        }
    }
}